<template>
    <!--最大div-->
    <div style="margin-top: -10px">
        <!--新建栏-->
        <div style="border:1px solid #BFBFBF;padding: 10px;background-color: white;margin-top: 10px;height: 40px">

            <el-row :gutter="24">
                <el-col :span="2">
                    <span style="font-size: 18px;line-height:40px;margin-left: 5px">日志</span>
                </el-col>
                <el-col :span="7">
                    <el-select v-model="fenlei" @change="changebusni" style="width: 150px;margin-left: 20px" placeholder="全部日志">
                        <el-option-group
                                v-for="group in options3"
                                :key="group.label"
                                :label="group.label">
                            <el-option
                                    v-for="item in group.options"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-option-group>
                    </el-select>
                    <el-button style="background-color: #F05050;color: white;margin-left: 10px;" @click="cancelseek" icon="el-icon-back" v-show="seek" size="mini" round>解除搜索</el-button>
                </el-col>
                <el-col :span="9">
                    <el-input placeholder="请输入搜索的信息" v-model="search" style="width: 250px;" @keyup.enter.native="ajaxLoginApi()">
                        <i slot="suffix" class="el-input__icon el-icon-search"></i>
                    </el-input>
                </el-col>
                <el-col :span="6">
                    <router-link style="line-height:40px;margin-left:80px;" :to="{path:'/rizizhu'}">
                        <el-button size="small"  type="primary" @click="jilutankuan=true">返回</el-button>
                    </router-link>
                </el-col>
            </el-row>
        </div>



        <!--表格数据框-->
        <div style="margin-top: 10px;border: 1px solid #BFBFBF;background-color: white">
            <div style="width: 100%;height: 40px;background-color: white;border-bottom: 1px solid #EBEEF5">
                <div class="operate" v-show="cjy">
                    <div class="selected—title" style="border-right: 0px ">
                        场景：<span>{{fenlei}}</span>
                    </div>
                </div>
                <div class="operate" v-show="cje">
                    <div class="selected—title" >
                        已选中<span class="selected—count">{{count}}</span>项
                    </div>
                    <div  class="selected—title2" v-show="isOne">
                        <span @click="isAddRecord=true"><i class="el-icon-circle-plus-outline"></i>添加跟进记录</span>
                    </div>
                    <div  class="selected—title1" v-show="isOne">
                        <span><i class="el-icon-edit"></i>修改</span>
                    </div>
                    <div  class="selected—title1">
                        <span><i class="el-icon-delete"></i>删除</span>
                    </div>
                </div>
            </div>
            <el-table
                    :data="Lrizhicxlist"
                    style="width: 100%"
                    max-height="450"
                    :default-sort = "{prop: 'date', order: 'descending'}"
                    @selection-change="handleSelectionChange">
                <el-table-column
                        type="selection"
                        width="50"
                        align="center">
                </el-table-column>
                <el-table-column
                        fixed
                        prop="rzId"
                        label="ID"
                        sortable
                        align="center"
                        width="70">
                </el-table-column>
                <el-table-column
                        fixed
                        prop="rzZhuti"
                        label="日志主题"
                        align="center"
                        width="120">
                </el-table-column>
                <el-table-column
                        prop="empId.empName"
                        label="用户"
                        align="center"
                        width="120">
                </el-table-column>
                <el-table-column
                        sortable
                        label="创建时间"
                        align="center"
                        width="120">
                    <template slot-scope="d">
                        {{d.row.rzCjtime | formatDate}}
                    </template>
                </el-table-column>
                <el-table-column
                        prop="rzDpzt"
                        label="点评状态"
                        align="center"
                        width="120"
                       >
                </el-table-column>
                <el-table-column
                        prop="rzLx"
                        label="日志类型"
                        align="center"
                        width="150">
                </el-table-column>
                <el-table-column
                        prop="rzNeirong"
                        label="日志内容"
                        align="center"
                >
                </el-table-column>
            </el-table>
        </div>

        <!--分页框-->
        <div style="margin-top: 15px;border: 1px solid #BFBFBF;padding: 10px;background-color: white">
            <div style="text-align: center">
                <el-pagination
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page.sync="currentPage"
                        :page-sizes="sizes"
                        :page-size="pageSize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="totalSize"
                >
                </el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
    import {formatTimeToStr} from '../router//format.js'
    export default {
        name: "Lrzb",
        data() {
            return {
                totalSize:10,
                pageSize:5,
                currentPage:1,
                sizes:[5, 10, 15, 20],
                multipleTable: [],//存放选中值的数组
                isOne:true,//选中项为1就出现添加跟进记录和修改
                //解除搜索是否显示
                seek:false,
                //下拉选择框
                options3: [{
                    label: '日志类型',
                    options: [{
                        value: '日报',
                        label: '日报'
                    }, {
                        value: '周报',
                        label: '周报'
                    }, {
                        value: '月报',
                        label: '月报'
                    }]
                }],
                fenlei: '',
                search:'',
                //场景一
                cjy:true,
                //场景二
                cje:false,
                //搜索框
                //表格
                Lrizhicxlist: [],
                //分页
            }
        }, methods: {

            //回车查询
            ajaxLoginApi(){
                this.initData(this.currentPage,this.pageSize,this.fenlei,this.search);
            },
            //分页
            initData(currentPage,pageSize,fenlei,search){
                this.$axios.get("http://localhost:8088/vue/Lrizhicx",{params:{currentPage:currentPage,pageSize:pageSize,fenlei:fenlei,search:search}}).then(v=>{
                    window.console.log(1);
                    this.Lrizhicxlist=v.data.row;
                    this.totalSize=v.data.total;
                    window.console.log(v.data);
                }).catch();
            },


            /*表格删除方法*/
            deleteRow(index, rows) {
                rows.splice(index, 1);
            },
            /*分页数方法*/
            handleSizeChange(val) {
                this.initData(1,this.pageSize=val,this.fenlei,this.search);
                window.console.log(`每页 ${val} 条`);
            },
            /*当前页方法*/
            handleCurrentChange(page) {
                this.initData(page,this.pageSize);
                window.console.log(`当前页: ${page}`);
            },
            //复选框选中的
            handleSelectionChange(val) {
                this.multipleTable = val;//  this.multipleTable 选中的值
                if(this.multipleTable.length>0){
                    this.cjy=false;//第一行隐藏
                    this.cje=true;//批量操作栏出现
                }
                //选中项大于1不能执行添加跟进记录和修改按钮
                if(this.multipleTable.length>1){
                    this.isOne=false;
                }else if(this.multipleTable.length==0){//选中项为0时
                    this.cjy=true;//第一行出现
                    this.cje=false;//批量操作栏隐藏
                }else{
                    this.isOne=true;//添加跟进记录和修改出现
                }
                window.console.log(val);
            },
            /*选择类型商机方法*/
            changebusni(){
                if(this.fenlei!=''){
                    this.seek=true;
                    this.initData(this.currentPage,this.pageSize,this.fenlei,this.search);
                }
            },
            /*解除选择类型商机方法*/
            cancelseek(){
                this.fenlei='';
                this.seek=false;
                this.initData(this.currentPage,this.pageSize);
            },
        },
        created:function(){

            //调用分页
            this.initData(this.currentPage,this.pageSize);

            //调用回车方法
            this.ajaxLoginApi();
            //下拉列查询
            this.changebusni();


        },
        computed:{


            count(){
                return this.multipleTable.length
            }
        },
        filters: {
            formatDate: function (time) {
                if (time != null && time != "") {
                    var date = new Date(time);
                    return formatTimeToStr(date, "yyyy-MM-dd");
                } else {
                    return "";
                }
            }
        },
        mounted () {

        },

    }
</script>

<style scoped>

    .addview:hover{
        color: white;
    }
    a{
        text-decoration: none;
        color: #409EFF;
    }
    a:hover{
        color: white;
    }
    .busin:hover{
        color: #3E84E9;
        cursor:pointer;
    }
    .businame{
        color: #606266;
    }
    .businame:hover{
        color: #409EFF;
        cursor:pointer;
    }
    .operate{
        font-size: 12px;
        height: 40px;
        padding: 0 20px;
        color: #777;
        background: white;
    }
    .selected—title{
        margin-top: 15px;
        margin-left: -6px;
        border-right: 1px solid #e6e6e6;
        width: 86px;
        height:20px;
        float: left;
    }
    .selected—title1{
        margin-top: 15px;
        border-right: 1px solid #e6e6e6;
        width: 86px;
        height:20px;
        float: left;
        cursor: pointer;
    }

    .selected—title1 span{
        margin-left: 24px;
    }
    .selected—title1 span:hover{
        color:#409eff;
    }
    .selected—title2{
        margin-top: 15px;
        border-right: 1px solid #e6e6e6;
        width: 129px;
        height:20px;
        float: left;
        cursor: pointer;
    }

    .selected—title2 span{
        margin-left: 24px;
    }
    .selected—title2 span:hover{
        color:#409eff;
    }
</style>